package com.ex.shapecalc;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;  
import java.lang.reflect.Field; 
import org.junit.Test;
 

public class HeartQuestionTest { 
	private static final double DELTA = 1e-15; 

//@Test
//	public void test1() {
//	HeartQuestionImpl testObj = new HeartQuestionImpl(){
//		public double teststub()
//		{
//			return 20;
//		}
//	 };
//	 double  act = testObj.testfun();
//	 double exp = 22;
//	 assertEquals(exp, act, DELTA);
//}
@Test
public void test() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
	//fail("Not yet implemented");  
	CircleQuestion mockedCircle = mock(CircleQuestion.class);  		 
//	when(mockedCircle.CalcArea()).thenReturn(Math.PI);
	mockedCircle.setmCircler(20);
	
	TriangleQuestion mockedTriangle = mock(TriangleQuestion.class);  
//	when(mockedTriangle.calcArea()).thenReturn(8.0);
	
	HeartQuestion testObj = new HeartQuestion();
	testObj.setmDownTriangle(mockedTriangle);
	
	Field field = HeartQuestion.class.getDeclaredField("mUpCircle");
	field.setAccessible(true);
	System.out.println(field.getType());
	CircleQuestion temp = (CircleQuestion)field.get(testObj);
	System.out.println(temp.getmCircler());
	
	field.set(testObj, mockedCircle);    
	System.out.println(((CircleQuestion)field.get(testObj)).getmCircler());
	
	//testObj.up = mockedCircle;
	

//	testObj.up.R = 1;
//	testObj.down.B = 4;
//	testObj.down.H = 4; 
	 testObj.CalcArea();
	double act = testObj.getRightArea();
	assertEquals(8 + Math.PI, act, DELTA); 
}

}
